using Cysharp.Threading.Tasks;
using HBFramework;
using UnityEngine;
using DG.Tweening;
public class Panel_Loading : BasePanel
{
    public override int RemainTime => PanelRemainTime.Permanent;

    public override int Layer => PanelLayer.Mask;

    public override string Path => "ui/panel_loading";

    private static Panel_Loading panel;
    private static CanvasGroup cg;

    public override void OnInit(GameObject ui)
    {
        panel = this;
        cg = ui.transform.Find("cg").GetComponent<CanvasGroup>();
    }

    public override void OnRelease()
    {

    }

    public static async UniTask ShowLoading()
    {
        PanelManager.Instance.ShowPanel(panel);
        cg.DOFade(1, 1f).ChangeStartValue(0);
        await UniTask.WaitForSeconds(1f);
    }

    public static async UniTask HideLoading()
    {
        cg.DOFade(1, .5f).ChangeStartValue(1);
        await UniTask.WaitForSeconds(.5f);
        PanelManager.Instance.HidePanel(panel);
    }
}
